How to use the calibration utility

This tool calibrates the input internally-calibrated continuously-represented mean spectra to the absolute system.

Information about the units of the variables used in this tutorial can be found here.

Basic usage

The calibrator returns two different outputs:

  1. The calibrated spectra which is a pandas DataFrame.
  2. The sampling passed to the function which is a NumPy array. If no sampling is given, the default sampling is returned. The default sampling is generated internally and it corresponds to numpy.arange(336., 1021., 2.) in absolute wavelengths [nm].

Input types

The input does not have to be a path to a file. There are other options: a pandas DataFrame, an ADQL query or a list of sourceIds.

Passing a DataFrame

Running a query

The calibrator can also take the parameters 'username' and 'password' for Cosmos credentials, instead of using the interactive login (like in the example below). See that information here.

Passing a list

A list of sourceIds can be passed to the calibrator as the first argument. The calibrator then will query the Archive for these objects.

The calibrator can also take the parameters 'username' and 'password' for Cosmos credentials, instead of using the interactive login (like in the example below). See that information here.

Advanced usage

Additional arguments can be passed to the calibrator.

These are:

  1. sampling
  2. truncation
  3. output_path
  4. output_file
  5. output_format
  6. save_file

Sampling

A sampling can be passed to the function. This sampling should be an iterable (list, tuple, generator, or preferably a NumPy array). If no sampling is given, the default sampling is used and returned.

The default sampling of the calibrator corresponds to numpy.arange(336., 1021., 2.) in absolute wavelengths [nm], and it is generated internally when no sampling is explicitly passed to the function.

The minimum value allowed in the sampling is 330, and the maximum is 1050. The program will raise an error is the sampling does not comply.

The sampling can be tailored to the needs of specific science cases. For example, the sampling numpy.geomspace(330,1049.9999999999, 361) could be employed to improve the resolution at the blue end.

We can compare the results of the default sampling and the suggested one for sourceId 6.

Truncation

The source mean BP/RP spectrum is described as a combination of basis functions. Particularly for faint sources or sources with a low number of observations, it is useful to represent the spectrum using a smaller set of basis functions to avoid higher-order bases fitting the noise in the observed data.

The truncation parameter is a boolean which toggles the truncation of the set of bases.

We can use GaiaXPy's plot spectra utility to see the differences in the results.

Output_path, output_file, output_format, save_file

Three parameters: output_path, output_file, and output_format define the entire path of the resulting file.

The default output path is the current path. If the given output path does not exist, it will be created.

The default output file name is 'output_spectra'.

The default output format is the format of the input file (i.e. if the input file is a 'fits', then the output file will be a FITS file by default.), or CSV in any other case (DataFrame, ADQL query or list).

NOTE: If a file with the same path and name already exists, it will be AUTOMATICALLY OVERWRITTEN.

The additional parameter save_file is a boolean that tells the program whether to save the results or not. If 'output_file' is given but 'save_file' is set to False, a warning will be raised.